package com.litblue.artwork.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.litblue.artwork.mapper.CategoryMapper;
import com.litblue.starter.core.AjaxResult;
import com.litblue.starter.pojo.artwork.domain.LitArtworkCategory;
import com.litblue.starter.pojo.artwork.dto.LitArtworkCategoryDto;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/art/category")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class CategoryController {

    private final CategoryMapper categoryMapper;


    @PostMapping("saveCategory")
    AjaxResult saveCategory (@RequestBody LitArtworkCategoryDto litArtworkCategoryDto){
        categoryMapper.insert(litArtworkCategoryDto);
        return new AjaxResult("success","200");
    }
    @GetMapping("getCategory")
    AjaxResult getCategory (){
        List<LitArtworkCategory> litArtworkCategories = categoryMapper.selectList(new QueryWrapper<LitArtworkCategory>());
        return new AjaxResult("查询成功","200",litArtworkCategories);
    }
}
